import axios from 'axios'

export function fetchTodos() {
  return axios.get('/api/get-todo')
}

export function addTodo(value) {
  return axios.post('/api/add-todo', {
    value,
    isCompleted: false
  })
}

export function updateTodo(id) {
  return axios.post(`/api/update-todo/${id}`)
}

export function deleteTodo(id) {
  return axios.post(`/api/del-todo/${id}`)
}

export function updateQuestion(userId, deviceId, type, question) {
  return axios.post('/api/teaching/updateQuestion', {
    user_id: Number(userId),
    device_id: Number(deviceId),
    type: String(type),
    question: question
  })
}

export function updateTeachingAnswer(userId, deviceId, type, answer) {
  return axios.post('/api/teaching/updateAnswer', {
    user_id: Number(userId),
    device_id: Number(deviceId),
    type: String(type),
    answer: answer
  })
}

export function getTeachingAnswer(userId, deviceId, type) {
  return axios.get(`/api/teaching/getAnswerByParams/${userId}/${deviceId}/${type}`)
}

export function getAllTeachingInfo() {
  return axios.get('/api/teaching/getAnswer')
}

export function clearTeachingTable() {
  return axios.post('/api/teaching/clearAll')
} 